package com.xxlie.auth.common;

import java.util.ArrayList;
import java.util.List;

import com.xxlie.auth.domain.Role;

/**
 * 角色名称
 * 
 * @author xxlie.com
 *
 */
public class RoleUtils {
	/**
	 * 管理员
	 */
	public static final String ADMIN = "administrator";
	/**
	 * 普通用户
	 */
	public static final String GENERAL = "general";

	public static List<String> getRoles(List<Role> roleList) {
		List<String> roles = new ArrayList<String>();
		for (Role role : roleList) {
			roles.add(role.getEnname());
		}
		return roles;
	}

	public static boolean hasRole(List<Role> roleList, String roleName) {
		return getRoles(roleList).contains(roleName);
	}
}
